package com.kaisa.activity.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Menu;
import android.view.MenuItem;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

import com.kaisa.activity.BaseApp;
import com.kaisa.activity.R;

import org.xutils.view.annotation.ViewInject;


public class GuideActivity extends AppCompatActivity {
    private ImageView textImageView;
    private ImageView contentImageView;
    private ImageView backImageView;
    private DisplayMetrics displayMetrics;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);
         displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        initView();
    }

    private void initView() {
        textImageView = (ImageView) this.findViewById(R.id.guide_text);
        contentImageView = (ImageView) this.findViewById(R.id.guide_content);
        Animation animation = new TranslateAnimation(textImageView.getX(),textImageView.getX(),textImageView.getY(),(displayMetrics.heightPixels)/3);
        animation.setDuration(2000);
        animation.setFillAfter(true);
        textImageView.startAnimation(animation);
        Animation animations = new TranslateAnimation(contentImageView.getX(),contentImageView.getX(),contentImageView.getY(),-(displayMetrics.heightPixels)/3);
        animations.setDuration(2000);
        animations.setFillAfter(true);
        contentImageView.startAnimation(animations);
       animations.setAnimationListener(new Animation.AnimationListener() {
           @Override
           public void onAnimationStart(Animation animation) {

           }

           @Override
           public void onAnimationEnd(Animation animation) {
               try {
                   Thread.sleep(2000);
                   Intent  i = new Intent(GuideActivity.this,WelcomeActivity.class);
                   startActivity(i);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }

           }

           @Override
           public void onAnimationRepeat(Animation animation) {

           }
       });
    }


}
